﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage/Edit.Master"  AutoEventWireup="true"  CodeBehind="Bu_AuditTable_FGW_Edit.aspx.cs" Inherits="Honestysoft.Financing.WebUI.Module.Audit.Bu_AuditTable_FGW_Edit"  %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<script language="javascript" type="text/javascript" src="../../Scripts/table.js"></script>
<script language="javascript" type="text/javascript">
        var opts = null;
        function InitRules() {
            
        }
        function selectAT() {
            if ($("#<%=ddlBatchNo.ClientID %>").val() == "0") {
                alert("请先选择批次后再执行此操作！");
                return false;
            }
            var retValue = window.showModalDialog("SelectFGWAT.aspx?BatchID=" + $("#<%=ddlBatchNo.ClientID %>").val(), window, 'scroll:0;status:0;help:1;resizable:0;dialogWidth:800px;dialogHeight:600px');
            if (typeof (retValue) != "undefined" && retValue != null && retValue != "") {
                $("#<%=hidAddATID.ClientID %>").val(retValue);
                return true;
            }
            return false;
        }
        function dataItem() {
	        var ID;
            var Opinion;
	    }
	    var DataItemArray = new Array();
	    function setFGWOpinion(id, txtId) {
	        setNewItem(id);
	        for (var i = 0; i < DataItemArray.length; i++) {
	            if (DataItemArray[i].ID == id) {
	                DataItemArray[i].Opinion = document.getElementById(txtId).value;
	                break;
	            }
	        }
        }
        function setNewItem(id) {
            var isExists = false;
            if (DataItemArray.length > 0) {
                for (var i = 0; i < DataItemArray.length; i++) {
                    if (DataItemArray[i].ID == id) {
                        isExists = true;
                        break;
                    }
                }
            }
            if (!isExists) {
                var newItem = new dataItem();
                newItem.ID = id;
                newItem.Opinion = "";
                DataItemArray.push(newItem);
            }
        }
        function checkSave() {
            //如果没有导入作业表，不能保存
            if ($("#<%=ddlBatchNo.ClientID %>").val() == "0") {
                alert("您没有指导本次支付汇总表所属的批次，不能进行保存操作！");
                return false;
            }
            if (tGrid.rows.length == 1) {
                alert('您没有导入本次支付汇总表包含的作业表，不能进行保存操作！');
                return false;
            }
            setOpinionString();
            return true;
        }
        function setOpinionString() {
            var str = "";
            if (DataItemArray.length > 0) {
                for (var i = 0; i < DataItemArray.length; i++) {
                    if (str != "") {
                        str += "|";
                    }
                    str += DataItemArray[i].ID + "@" + DataItemArray[i].Opinion;
                }
            }
            document.getElementById("<%=hidFGWOpinion.ClientID %>").value = str;
        }
        function dateChange(ctl) {
            if (ctl.value == "") {
                alert("必须选择日期！");
                ctl.value = getCurrentDate();
            }
        }
        function getCurrentDate() {
            var now = new Date();
            var year = now.getFullYear();       //年
            var month = now.getMonth() + 1;     //月
            var day = now.getDate();            //日
            var clock = year + "-";
            if (month < 10) {
                clock += "0";
            }
            clock += month + "-";
            if (day < 10) {
                clock += "0";
            }
            clock += day;
            return clock;
        } 
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="infoContainer">注意：只能选择生成了《融资项目第X批资金支付申请初审情况汇总表》的批次，如果没有可选批次，请重新进入“统计查询-资金申请汇总表”，输入批次及日期，点击查询来生成报告记录；批次选择后，自动生成汇总表的次数，备注等信息。</div>
        <table cellpadding="0" width="100%" cellspacing="0" border="1" class="tEdit" style="border-bottom:0px;margin-top:2px;">
            <th style="border-bottom:0px">融资项目第<asp:DropDownList runat="server" ID="ddlBatchNo" 
                    cssClass="input2" BackColor="Yellow" AutoPostBack="true" 
                    onselectedindexchanged="ddlBatchNo_SelectedIndexChanged"></asp:DropDownList>批第<asp:TextBox ID="numCounter" runat="server"  cssClass="input2" onbeforepaste="numboxPaste();" onkeypress="isInt();" Width="50px" Enabled="false"></asp:TextBox>次资金支付汇总表</th>
            
        </table>
        <table cellpadding="0" width="100%" cellspacing="0" border="1" class="tEdit">
		
		<tr>
			<td class="title1">打印日期</td>
			<td><asp:TextBox ID="dtpPrintDate" runat="server" cssClass="input2" onfocus="setday(this);" BackColor="Yellow"  Width="96%" onpropertychange="dateChange(this);" ></asp:TextBox>
            </td>
            <td class="title1">制表</td>
            <td><asp:TextBox ID="txtCreator" runat="server"  cssClass="input2" MaxLength="200" Width="96%" Enabled="false"></asp:TextBox>
           </td>
			<td class="title1">深超公司报送日期</td>
			<td><asp:TextBox ID="dtpReportDate" runat="server" cssClass="input2" onfocus="setday(this);" Width="96%" Enabled="false"></asp:TextBox>
            </td>
		</tr>        
        
		<tr>
			<td class="title1">备注[1]</td>
			<td colspan="5"><asp:TextBox ID="txtRemark1" runat="server"  cssClass="input2"  Width="96%"  Enabled="false"></asp:TextBox></td>
			
		</tr>
        <tr>
            <td class="title1">备注[2]</td>
			<td colspan="5"><asp:TextBox ID="txtRemark2" runat="server"  cssClass="input2" TextMode="MultiLine" Rows="3" Width="96%"  Enabled="false"></asp:TextBox></td>
        </tr>
        <tr>
            <td colspan="6">
                <div class="button_area">
                
                    <asp:Button runat="server" ID="btnAdd" CssClass="btn_big_normal"  OnClientClick="return selectAT();"
			            onMouseOver="this.className='btn_big_active'" 
                        onMouseOut="this.className='btn_big_normal'" Text="选择作业表" 
                        onclick="btnAdd_Click"/><span style="color:Red">（提示：选择完作业表后，可修改审核意见！）</span>
                    <asp:Button runat="server" ID="btnDelete" CssClass="btn_normal" 
			            onMouseOver="this.className='btn_active'" 
                        onMouseOut="this.className='btn_normal'" Text="删除"  
                        
                        OnClientClick="javascript:return getNoSelectionAlert('chkID','请选择要删除的记录后在执行此操作！');" onclick="btnDelete_Click"             
                         />
                         <asp:HiddenField runat="server" ID="hidAddATID" />
                </div>
                 <div style="overflow:scroll;height:300px;width:100%">

    <table cellpadding="0" width="100%" cellspacing="0" border="1" class="t1" id="tGrid">
		<thead>  
            <th align="center" width="30px">
                <input type="checkbox" name="chkAll" value="checkbox" onclick='javascript:checkAll(this,"chkID")' />
            </th>            
            <th align="center" width="110px">审核作业表编号</th>
            <th align="center" width="150px" style="display:none" >项目名称</th>
            <th align="center" width="150px" style="display:none" >建设单位</th>            
            <th align="center" width="150px" style="display:none" >项目项下合同</th>
            <th align="center" width="150px" style="display:none" >施工\监理单位</th>
            <th align="center" width="100px">请款金额（元）A</th>
            <th align="center" width="100px">初审金额（元）B</th>            
            <th align="center" width="100px">本合同前期累计拨款金额（元）C</th>
            <th align="center" width="100px">本合同总价金额（元）D</th>
            <th align="center" width="100px">申请付款比例(A+C)/D*100%</th>
            <th align="center" width="100px">实际付款比例(B+C)/D*100%</th>            
            <th align="center" width="200px">审核意见</th>
      	</thead>           
		<asp:Repeater runat="server" ID="rptList" 
            onitemdatabound="rptList_ItemDataBound">
			<ItemTemplate>
				<tr>
					<td align="center" >
						<input type="checkbox" name="chkID" id="chk<%# DataBinder.Eval(Container.DataItem,"ID") %>"  value="<%# DataBinder.Eval(Container.DataItem,"ID") %>" >
					</td>       
					<td style="text-align:left"><a href="AuditTable_Edit.aspx?ID=<%# DataBinder.Eval(Container.DataItem,"ID") %>&FunctionID=<%=Request["FunctionID"] %>" target="_blank" title='项目名称：<%#DataBinder.Eval(Container.DataItem, "ProjectName")%>&#13;建设单位：<%#  DataBinder.Eval(Container.DataItem, "OwnerName")%>&#13;项目项下合同：<%#  DataBinder.Eval(Container.DataItem, "ContractName")%>&#13;施工\监理单位：<%#  DataBinder.Eval(Container.DataItem, "ContractorName")%>'><%#  DataBinder.Eval(Container.DataItem,"Code") %></a> </td>
                    <td style="text-align:left;display:none" ><%#DataBinder.Eval(Container.DataItem, "ProjectName")%></td>
                    <td style="text-align:left;display:none" ><%#  DataBinder.Eval(Container.DataItem, "OwnerName")%></td>
                    <td style="text-align:left;display:none"><%#  DataBinder.Eval(Container.DataItem, "ContractName")%></td>
                    <td style="text-align:left;display:none"  ><%#  DataBinder.Eval(Container.DataItem, "ContractorName")%></td>
                    <td style="text-align:right"><%# string.Format("{0:N}", DataBinder.Eval(Container.DataItem, "Amount_DocRec_S"))%></td>
                    <td style="text-align:right"><%# string.Format("{0:N}", DataBinder.Eval(Container.DataItem, "Amount_S"))%></td>
                    <td style="text-align:right"><%# string.Format("{0:N}",  DataBinder.Eval(Container.DataItem, "TAmount_C_A_S"))%></td>
                    <td style="text-align:right"><%# string.Format("{0:N}",  DataBinder.Eval(Container.DataItem, "Amount_C_S"))%></td>
                    <td>
						<%# GetPDocRec(Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "Amount_DocRec_S")), Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "TAmount_C_A_S")), Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "Amount_C_S")))%>
					</td>
                    <td>
						<%# GetPS(Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "Amount_S")), Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "TAmount_C_A_S")), Convert.ToDecimal(DataBinder.Eval(Container.DataItem, "Amount_C_S")))%>
					</td>             
                    <td><asp:TextBox ID="txtOpinion" runat="server"  class="input2" Width="200"  ></asp:TextBox></td>
				</tr>  
			</ItemTemplate>
		</asp:Repeater>
    </table>
    </div>
    <iframe id="ifrmReload"  frameborder="0"  src="AutoReloadFGWSession.aspx" style="width:0;height:0;"></iframe> 
    <asp:HiddenField runat="server" ID="hidFGWOpinion" />
     <script language="javascript" type="text/javascript">
         uniteTable(tGrid, 5);
        setGridView2('tGrid'); //列表的table的id
   </script>
            </td>
        </tr>
        </table>
        <div class="save_area">
            <asp:Button runat="server" ID="btnOK" Text="确定" class="btn_normal" 
                onmouseover="this.className='btn_active'" 
                onmouseout="this.className='btn_normal'" OnClientClick="return checkSave()" onclick="btnOK_Click"/>
            <input type="button" id="btnExit" value="取消" onclick="javascript:window.returnValue=false;window.close();" class="btn_normal" onmouseover="this.className='btn_active'" onmouseout="this.className='btn_normal'" />
             </div>

</asp:Content>


